all_features: options.flag_all_features,
no_default_features: options.flag_no_default_features,
spec: &options.flag_package,
- exec_engine: None,
release: true,
mode: ops::CompileMode::Bench,
filter: ops::CompileFilter::new(options.flag_lib,
all_features: options.flag_all_features,
no_default_features: options.flag_no_default_features,
spec: &options.flag_package,
- exec_engine: None,
mode: ops::CompileMode::Build,
release: options.flag_release,
filter: ops::CompileFilter::new(options.flag_lib,
all_features: options.flag_all_features,
no_default_features: options.flag_no_default_features,
spec: &options.flag_package,
- exec_engine: None,
filter: ops::CompileFilter::new(options.flag_lib,
&options.flag_bin,
&empty,
all_features: options.flag_all_features,
no_default_features: options.flag_no_default_features,
spec: &[],
- exec_engine: None,
mode: ops::CompileMode::Build,
release: !options.flag_debug,
filter: ops::CompileFilter::new(false, &options.flag_bin, &[],
all_features: options.flag_all_features,
no_default_features: options.flag_no_default_features,
spec: &[],
- exec_engine: None,
release: options.flag_release,
mode: ops::CompileMode::Build,
filter: if examples.is_empty() && bins.is_empty() {
all_features: options.flag_all_features,
no_default_features: options.flag_no_default_features,
spec: &options.flag_package.map_or(Vec::new(), |s| vec![s]),
- exec_engine: None,
mode: mode,
release: options.flag_release,
filter: ops::CompileFilter::new(options.flag_lib,
all_features: options.flag_all_features,
no_default_features: options.flag_no_default_features,
spec: &options.flag_package.map_or(Vec::new(), |s| vec![s]),
- exec_engine: None,
release: options.flag_release,
filter: ops::CompileFilter::new(options.flag_lib,
&options.flag_bin,
all_features: options.flag_all_features,
no_default_features: options.flag_no_default_features,
spec: &options.flag_package,
- exec_engine: None,
release: options.flag_release,
mode: mode,
filter: filter,
use std::collections::HashMap;
use std::path::PathBuf;
-use std::sync::Arc;
use core::registry::PackageRegistry;
use core::{Source, SourceId, PackageSet, Package, Target};
use core::{Profile, TargetKind, Profiles, Workspace, PackageIdSpec};
use core::resolver::{Method, Resolve};
-use ops::{self, BuildOutput, ExecEngine};
+use ops::{self, BuildOutput};
use sources::PathSource;
use util::config::Config;
use util::{CargoResult, profile, human, ChainError};
/// Filter to apply to the root package to select which targets will be
/// built.
pub filter: CompileFilter<'a>,
- /// Engine which drives compilation
- pub exec_engine: Option<Arc<Box<ExecEngine>>>,
/// Whether this is a release build or not
pub release: bool,
/// Mode for this compile.
let CompileOptions { config, jobs, target, spec, features,
all_features, no_default_features,
release, mode, message_format,
- ref filter, ref exec_engine,
+ ref filter,
ref target_rustdoc_args,
ref target_rustc_args } = *options;
let mut ret = {
let _p = profile::start("compiling");
let mut build_config = try!(scrape_build_config(config, jobs, target));
- build_config.exec_engine = exec_engine.clone();
build_config.release = release;
build_config.test = mode == CompileMode::Test;
build_config.json_errors = message_format == MessageFormat::Json;
all_features: false,
spec: &[],
filter: ops::CompileFilter::Everything,
- exec_engine: None,
release: false,
message_format: ops::MessageFormat::Human,
mode: ops::CompileMode::Build,
--- /dev/null
+use std::collections::HashMap;
+use std::ffi::{OsStr, OsString};
+use std::fmt;
+use std::path::Path;
+
+use util::{CargoResult, ProcessBuilder, process};
+use util::Config;
+
+/// Prototype for a command that must be executed.
+#[derive(Clone)]
+pub struct CommandPrototype {
+ ty: CommandType,
+ builder: ProcessBuilder,
+}
+
+impl CommandPrototype {
+ pub fn new(ty: CommandType, config: &Config)
+ -> CargoResult<CommandPrototype> {
+ Ok(CommandPrototype {
+ builder: {
+ let mut p = match ty {
+ CommandType::Rustc => try!(config.rustc()).process(),
+ CommandType::Rustdoc => process(&*try!(config.rustdoc())),
+ CommandType::Target(ref s) |
+ CommandType::Host(ref s) => process(s),
+ };
+ p.cwd(config.cwd());
+ p
+ },
+ ty: ty,
+ })
+ }
+
+ pub fn get_type(&self) -> &CommandType { &self.ty }
+
+ pub fn arg<T: AsRef<OsStr>>(&mut self, arg: T) -> &mut CommandPrototype {
+ self.builder.arg(arg);
+ self
+ }
+
+ pub fn args<T: AsRef<OsStr>>(&mut self, arguments: &[T]) -> &mut CommandPrototype {
+ self.builder.args(arguments);
+ self
+ }
+
+ pub fn cwd<T: AsRef<OsStr>>(&mut self, path: T) -> &mut CommandPrototype {
+ self.builder.cwd(path);
+ self
+ }
+
+ pub fn env<T: AsRef<OsStr>>(&mut self, key: &str, val: T)
+ -> &mut CommandPrototype {
+ self.builder.env(key, val);
+ self
+ }
+
+ pub fn get_args(&self) -> &[OsString] { self.builder.get_args() }
+ pub fn get_cwd(&self) -> Option<&Path> { self.builder.get_cwd() }
+
+ pub fn get_env(&self, var: &str) -> Option<OsString> {
+ self.builder.get_env(var)
+ }
+
+ pub fn get_envs(&self) -> &HashMap<String, Option<OsString>> {
+ self.builder.get_envs()
+ }
+
+ pub fn into_process_builder(self) -> ProcessBuilder {
+ self.builder
+ }
+}
+
+impl fmt::Display for CommandPrototype {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ self.builder.fmt(f)
+ }
+}
+
+#[derive(Clone, Debug)]
+pub enum CommandType {
+ Rustc,
+ Rustdoc,
+
+ /// The command is to be executed for the target architecture.
+ Target(OsString),
+
+ /// The command is to be executed for the host architecture.
+ Host(OsString),
+}
use super::layout::{Layout, LayoutProxy};
use super::links::Links;
use super::{Kind, Compilation, BuildConfig};
-use super::{ProcessEngine, ExecEngine};
#[derive(Clone, Copy, Eq, PartialEq, Hash)]
pub struct Unit<'a> {
pub packages: &'a PackageSet<'cfg>,
pub build_state: Arc<BuildState>,
pub build_explicit_deps: HashMap<Unit<'a>, (PathBuf, Vec<String>)>,
- pub exec_engine: Arc<Box<ExecEngine>>,
pub fingerprints: HashMap<Unit<'a>, Arc<Fingerprint>>,
pub compiled: HashSet<Unit<'a>>,
pub build_config: BuildConfig,
None => None,
};
- let engine = build_config.exec_engine.as_ref().cloned().unwrap_or({
- Arc::new(Box::new(ProcessEngine))
- });
let current_package = try!(ws.current()).package_id().clone();
Ok(Context {
host: host_layout,
compilation: Compilation::new(config),
build_state: Arc::new(BuildState::new(&build_config)),
build_config: build_config,
- exec_engine: engine,
fingerprints: HashMap::new(),
profiles: profiles,
compiled: HashSet::new(),
+++ /dev/null
-use std::collections::HashMap;
-use std::ffi::{OsStr, OsString};
-use std::fmt;
-use std::path::Path;
-use std::process::Output;
-
-use util::{CargoResult, ProcessError, ProcessBuilder, process};
-use util::Config;
-
-/// Trait for objects that can execute commands.
-pub trait ExecEngine: Send + Sync {
- fn exec(&self, CommandPrototype) -> Result<(), ProcessError>;
- fn exec_with_output(&self, CommandPrototype) -> Result<Output, ProcessError>;
-}
-
-/// Default implementation of `ExecEngine`.
-#[derive(Clone, Copy)]
-pub struct ProcessEngine;
-
-impl ExecEngine for ProcessEngine {
- fn exec(&self, command: CommandPrototype) -> Result<(), ProcessError> {
- command.into_process_builder().exec()
- }
-
- fn exec_with_output(&self, command: CommandPrototype)
- -> Result<Output, ProcessError> {
- command.into_process_builder().exec_with_output()
- }
-}
-
-/// Prototype for a command that must be executed.
-#[derive(Clone)]
-pub struct CommandPrototype {
- ty: CommandType,
- builder: ProcessBuilder,
-}
-
-impl CommandPrototype {
- pub fn new(ty: CommandType, config: &Config)
- -> CargoResult<CommandPrototype> {
- Ok(CommandPrototype {
- builder: {
- let mut p = match ty {
- CommandType::Rustc => try!(config.rustc()).process(),
- CommandType::Rustdoc => process(&*try!(config.rustdoc())),
- CommandType::Target(ref s) |
- CommandType::Host(ref s) => process(s),
- };
- p.cwd(config.cwd());
- p
- },
- ty: ty,
- })
- }
-
- pub fn get_type(&self) -> &CommandType { &self.ty }
-
- pub fn arg<T: AsRef<OsStr>>(&mut self, arg: T) -> &mut CommandPrototype {
- self.builder.arg(arg);
- self
- }
-
- pub fn args<T: AsRef<OsStr>>(&mut self, arguments: &[T]) -> &mut CommandPrototype {
- self.builder.args(arguments);
- self
- }
-
- pub fn cwd<T: AsRef<OsStr>>(&mut self, path: T) -> &mut CommandPrototype {
- self.builder.cwd(path);
- self
- }
-
- pub fn env<T: AsRef<OsStr>>(&mut self, key: &str, val: T)
- -> &mut CommandPrototype {
- self.builder.env(key, val);
- self
- }
-
- pub fn get_args(&self) -> &[OsString] { self.builder.get_args() }
- pub fn get_cwd(&self) -> Option<&Path> { self.builder.get_cwd() }
-
- pub fn get_env(&self, var: &str) -> Option<OsString> {
- self.builder.get_env(var)
- }
-
- pub fn get_envs(&self) -> &HashMap<String, Option<OsString>> {
- self.builder.get_envs()
- }
-
- pub fn into_process_builder(self) -> ProcessBuilder {
- self.builder
- }
-}
-
-impl fmt::Display for CommandPrototype {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- self.builder.fmt(f)
- }
-}
-
-#[derive(Clone, Debug)]
-pub enum CommandType {
- Rustc,
- Rustdoc,
-
- /// The command is to be executed for the target architecture.
- Target(OsString),
-
- /// The command is to be executed for the host architecture.
- Host(OsString),
-}
use super::{Context, Kind, Unit};
use super::job::Job;
-use super::engine::CommandPrototype;
+use super::command::CommandPrototype;
/// A management structure of the entire dependency graph to compile.
///
pub use self::compilation::Compilation;
pub use self::context::{Context, Unit};
-pub use self::engine::{CommandPrototype, CommandType, ExecEngine, ProcessEngine};
+pub use self::command::{CommandPrototype, CommandType};
pub use self::layout::{Layout, LayoutProxy};
pub use self::custom_build::{BuildOutput, BuildMap, BuildScripts};
-mod context;
+mod command;
mod compilation;
+mod context;
mod custom_build;
-mod engine;
mod fingerprint;
mod job;
mod job_queue;
pub requested_target: Option<String>,
pub target: TargetConfig,
pub jobs: u32,
- pub exec_engine: Option<Arc<Box<ExecEngine>>>,
pub release: bool,
pub test: bool,
pub doc_all: bool,
let name = unit.pkg.name().to_string();
let build_state = cx.build_state.clone();
let key = (unit.pkg.package_id().clone(), unit.kind);
- let exec_engine = cx.exec_engine.clone();
Ok(Work::new(move |state| {
if let Some(output) = build_state.outputs.lock().unwrap().get(&key) {
}
}
state.running(&rustdoc);
- exec_engine.exec(rustdoc).chain_error(|| {
+ rustdoc.into_process_builder().exec().chain_error(|| {
human(format!("Could not document `{}`.", name))
})
}))
use std::ffi::{OsString, OsStr};
-use ops::{self, ExecEngine, ProcessEngine, Compilation};
+use ops::{self, Compilation};
use util::{self, CargoResult, CargoTestError, ProcessError};
use core::Workspace;
shell.status("Running", cmd.to_string())
}));
- if let Err(e) = ExecEngine::exec(&ProcessEngine, cmd) {
+ if let Err(e) = cmd.into_process_builder().exec() {
errors.push(e);
if !options.no_fail_fast {
break
try!(config.shell().verbose(|shell| {
shell.status("Running", p.to_string())
}));
- if let Err(e) = ExecEngine::exec(&ProcessEngine, p) {
+ if let Err(e) = p.into_process_builder().exec() {
errors.push(e);
if !options.no_fail_fast {
return Ok(errors);
pub use self::cargo_rustc::{compile_targets, Compilation, Layout, Kind, Unit};
pub use self::cargo_rustc::{Context, LayoutProxy};
pub use self::cargo_rustc::{BuildOutput, BuildConfig, TargetConfig};
-pub use self::cargo_rustc::{CommandType, CommandPrototype, ExecEngine, ProcessEngine};
+pub use self::cargo_rustc::{CommandType, CommandPrototype};
pub use self::cargo_run::run;
pub use self::cargo_install::{install, install_list, uninstall};
pub use self::cargo_new::{new, init, NewOptions, VersionControl};